package com.newegg.datafeed.adserving.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.newegg.datafeed.adserving.domain.Admin;

@Mapper
public interface AdminMapper {

	@Select("SELECT username,password,nickname,memo FROM admin where username=#{username} AND password=#{password}")
	Admin login(@Param("username") String username,@Param("password") String password);
	
	@Select("SELECT username,password,nickname,memo FROM admin")
	List<Admin> getAll();
	
	@Insert("INSERT INTO admin(username,password,nickname,memo) VALUES (#{username},#{password},#{nickname},#{memo});")
    void insert(Admin admin);
	
	@Update("UPDATE admin SET password=#{password},nickname=#{nickname},memo=#{memo} WHERE username=#{username}")
    void update(Admin admin);
	
	@Delete("DELETE FROM admin WHERE username=#{username}")
    void delete(String username);
}
